Skip to content

feat: customise html styles#1567

Merged
Sembauke merged 3 commits into
freeCodeCamp:mainfrom
Nirajn2311:feat/customise-html-styles
Jul 3, 2025
Merged

feat: customise html styles#1567
Sembauke merged 3 commits into
freeCodeCamp:mainfrom
Nirajn2311:feat/customise-html-styles

Conversation

@Nirajn2311
Copy link
Copy Markdown
Member

Checklist:

Instead of adding new variables when we want to customise the html styles, I updated the parser to accept custom styles and merge them with default ones.

@Nirajn2311 Nirajn2311 requested a review from a team June 26, 2025 16:21
@Nirajn2311 Nirajn2311 force-pushed the feat/customise-html-styles branch from d208a58 to 1f4847a Compare June 26, 2025 16:24
@Nirajn2311 Nirajn2311 mentioned this pull request Jun 27, 2025
4 tasks
Comment thread mobile-app/lib/ui/views/learn/widgets/assignment_widget.dart Outdated
Comment thread mobile-app/lib/ui/views/learn/widgets/assignment_widget.dart Outdated
Comment thread mobile-app/lib/ui/views/learn/widgets/quiz_widget.dart Outdated
import 'dart:convert';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:collection/collection.dart';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with adding another package, but I think there is a simpler solution that helps us override the default values: https://stackoverflow.com/a/71992310/9138914

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So using rest operators won't work as it will completely replace the value for a given key. So if we have a default style for h1 and a custom style comes in for h1 then the whole default style is lost for h1. But we don't want that as we want the styles to be merged if present in both places.

I can replace it with my own code to compare and merge the styles if we don't want to add in another package but I believe this package will help us in the long run as it has many helper functions for working with collections and it's an official package by dart devs.

Here's an example

void main() {
  print({
    ...{
      'a': {'aa': 1, 'ab': 2},
      'b': {'ba': 3},
    },
    ...{'a': {'ac': 5}},
  });
}

The output will be: {a: {ac: 5}, b: {ba: 3}}

@Nirajn2311 Nirajn2311 force-pushed the feat/customise-html-styles branch from 1f4847a to a162dfd Compare July 1, 2025 16:59
Co-authored-by: Sem Bauke <semboot699@gmail.com>
@Sembauke Sembauke merged commit 2afdf91 into freeCodeCamp:main Jul 3, 2025
3 of 6 checks passed
@Nirajn2311 Nirajn2311 deleted the feat/customise-html-styles branch July 4, 2025 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants